package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CleaningConfig;
import com.ruoyi.system.service.ICleaningConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清洗配置表管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-22
 */
@RestController
@RequestMapping("/system/cleanConfig")
public class CleaningConfigController extends BaseController
{
    @Autowired
    private ICleaningConfigService cleaningConfigService;

    /**
     * 查询清洗配置表管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(CleaningConfig cleaningConfig)
    {
        startPage();
        List<CleaningConfig> list = cleaningConfigService.selectCleaningConfigList(cleaningConfig);
        return getDataTable(list);
    }

    /**
     * 导出清洗配置表管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:export')")
    @Log(title = "清洗配置表管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CleaningConfig cleaningConfig)
    {
        List<CleaningConfig> list = cleaningConfigService.selectCleaningConfigList(cleaningConfig);
        ExcelUtil<CleaningConfig> util = new ExcelUtil<CleaningConfig>(CleaningConfig.class);
        util.exportExcel(response, list, "清洗配置表管理数据");
    }

    /**
     * 获取清洗配置表管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:query')")
    @GetMapping(value = "/{cleaningConfigId}")
    public AjaxResult getInfo(@PathVariable("cleaningConfigId") Long cleaningConfigId)
    {
        return success(cleaningConfigService.selectCleaningConfigByCleaningConfigId(cleaningConfigId));
    }

    /**
     * 新增清洗配置表管理
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:add')")
    @Log(title = "清洗配置表管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CleaningConfig cleaningConfig)
    {
        return toAjax(cleaningConfigService.insertCleaningConfig(cleaningConfig));
    }

    /**
     * 修改清洗配置表管理
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:edit')")
    @Log(title = "清洗配置表管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CleaningConfig cleaningConfig)
    {
        return toAjax(cleaningConfigService.updateCleaningConfig(cleaningConfig));
    }

    /**
     * 删除清洗配置表管理
     */
    @PreAuthorize("@ss.hasPermi('system:cleanConfig:remove')")
    @Log(title = "清洗配置表管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cleaningConfigIds}")
    public AjaxResult remove(@PathVariable Long[] cleaningConfigIds)
    {
        return toAjax(cleaningConfigService.deleteCleaningConfigByCleaningConfigIds(cleaningConfigIds));
    }
}
